package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    //1.插入微博
   // @Insert("INSERT INTO weibo (content,created,user_id) VALUES" +
     //       " (#{content},#{created},#{userId})")
   // void insertWeibo(Weibo weibo);
    int insertWeibo(Weibo weibo);
    //2.删除微博
    //@Delete("DELETE FROM weibo WHERE id=#{weiboId}")
    int deleteWeibo(Long weiboId);

//    @Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId}" +
//            " WHERE id=#{id}")
    int updateWeibo(Weibo weibo);

    /**
     * 查看一条信息
     * @param weiboId
     * @return
     */
   // @Select("SELECT id,content,created,user_id userId FROM weibo WHERE id=#{weiboId}")
    Weibo selectWeiboById(Long weiboId);
    /**
     * 多条数据全字段查寻
     */
   // @Select("SELECT id,content,created,user_id userId FROM weibo")
    List<Weibo> selectWeibo();
    //2024年6月7日
    //6单条数据部分字段查询
    //@Select("SELECT content,created FROM weibo WHERE id=#{weiboId}")
    SelectWeiboVO1 selectWeiboVO1(Long weiboId);


   // @Select("SELECT id,content FROM weibo WHERE user_id=#{userId}")
    List<SelectWeiboVO2> selectWeiboByUserId(Long userId);


    //8.动态修改微博信息
    int dynamicUpdateWeibo(Weibo weibo);
    //9.动态删除微博信息
    int dynamicDeleteWeibo1(Long[] ids);

    //集合方式删除
    int dynamicDeleteWeibo2(List<Long> ids);
    //统计数量
    int selectCount();

//ResultMap表单
    ResultMapVO1 selectResultMapVO1(Long weiboId);

    //ResultMap多表
    ResultMapVO2 selectResultMapVO2(Long userId);

    ResultMapVO4 selectResultMapVO4(Long weiboId);



}
